import { EntitySchema } from '@mikro-orm/core';

export class TypechoApp {
  id!: number;
  key?: string;
  name?: string;
  type?: string;
  logo?: string;
  keywords?: string;
  description?: string;
  announcement?: string;
  mail?: string;
  website?: string;
  currencyName?: string;
  version?: string;
  versionCode?: number = 10;
  versionIntro?: string;
  androidUrl?: string;
  iosUrl?: string;
  field1?: string;
  field2?: string;
  adpid?: string;
}

export const TypechoAppSchema = new EntitySchema({
  class: TypechoApp,
  properties: {
    id: { primary: true, type: 'number' },
    key: { type: 'string', length: 255, nullable: true },
    name: { type: 'string', length: 255, nullable: true },
    type: { type: 'string', length: 255, nullable: true, default: 'app' },
    logo: { type: 'string', length: 500, nullable: true },
    keywords: { type: 'string', length: 255, nullable: true },
    description: { type: 'string', length: 255, nullable: true },
    announcement: { type: 'string', length: 400, nullable: true },
    mail: { type: 'string', length: 400, nullable: true },
    website: { type: 'string', length: 400, nullable: true },
    currencyName: { type: 'string', fieldName: 'currencyName', length: 255, nullable: true },
    version: { type: 'string', length: 255, nullable: true, default: 'v1.0.0 beta' },
    versionCode: { type: 'number', fieldName: 'versionCode', nullable: true, default: 10 },
    versionIntro: { type: 'string', fieldName: 'versionIntro', length: 400, nullable: true },
    androidUrl: { type: 'string', fieldName: 'androidUrl', length: 400, nullable: true },
    iosUrl: { type: 'string', fieldName: 'iosUrl', length: 255, nullable: true },
    field1: { type: 'string', length: 400, nullable: true },
    field2: { type: 'string', length: 400, nullable: true },
    adpid: { type: 'string', length: 255, nullable: true },
  },
});
